package com.usian.model.comment;

/**
 * @author 任小龙
 * @date 2023/6/28
 */
import com.usian.model.common.annotation.IdEncrypt;
import lombok.Data;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

@Data
public class CommentDto {

    /**
     * 文章id
     */
    @IdEncrypt
    private Long articleId;

    // 最小时间
    private Date minDate = new Date();

    //是否是首页
    private Short index;

    public Long getArticleId() {
        return articleId;
    }

    public void setArticleId(Long articleId) {
        this.articleId = articleId;
    }

    public Date getMinDate() {
        return minDate;
    }

    public void setMinDate(Date minDate) {
        this.minDate = minDate;
    }

    public Short getIndex() {
        return index;
    }

    public void setIndex(Short index) {
        this.index = index;
    }
//
    /*@Override
    public boolean equals(Object obj) {
        if (this.hashCode() == obj.hashCode()){
            if (obj instanceof CommentDto){
                CommentDto dto = (CommentDto) obj;
                return this.getArticleId() == dto.getArticleId();
            }else  return false;
        }
        return false;
    }

    @Override
    public int hashCode() {
        return Objects.hash(articleId);
    }*/

    public static void main(String[] args) {
        CommentDto commentDto = new CommentDto();
        commentDto.setArticleId(4l);
        CommentDto commentDto1 = new CommentDto();
        commentDto1.setArticleId(4l);
        System.out.println(commentDto.hashCode() == commentDto1.hashCode());
        System.out.println(commentDto.equals(commentDto1));
        Set set = new HashSet();
        set.add(commentDto);
        set.add(commentDto1);
        System.out.println(set.size());
    }

}